<template>
  <van-nav-bar
    title="发布种草"
    left-text="返回"
    right-text="发布"
    fixed
    placeholder
    @click-left="goBack"
    @click-right="submitShare"
  />

  <div class="share-form">
    <!-- <van-field v-model="title" placeholder="输入标题" maxlength="30" label="标题" /> -->
    
    <van-field v-model="link" placeholder="粘贴商品链接" label="商品链接" />

    <van-field
      v-model="content"
      placeholder="来吧，尽情发挥吧"
      type="textarea"
      autosize
      maxlength="200"
      show-word-limit
      label="发表文字"
    />
    

    <van-field name="thumbs" label="">
      <template #input>
        <van-uploader
          v-model="images"
          multiple :max-count="9"
        />
      </template>
    </van-field>


  </div>
</template>

<script setup>
import { showToast } from 'vant'
const {proxy} = getCurrentInstance()
const content = ref('');
const images = ref([]);
const link = ref('');



const goBack = () => proxy.$router.go(-1);

const submitShare = async () => {
  if (!link.value || !content.value) {
    showToast('请填写内容和链接');
  }

  const HashParams = link.value.split('#')[1];
  const UrlParams = new URLSearchParams(HashParams.split('?')[1])
  // const UrlParams = new URLSearchParams(link.value)
  const proid = UrlParams.get('proid')
  
  var params = {
    content: content.value,
    images: images.value,
    link: link.value,
    proid
  };


};
</script>

<style scoped>
::v-deep .van-cell__title{
  width: 20%;
}
::v-deep .van-uploader__wrapper{
  justify-content: space-around;
}
.share-form {
  padding: 15px;
}
</style>
